<?php
// 提交更改密码
// header("content-type:text/html;charset=UTF-8");
include_once("conn.php");
include_once("d_getLoginInfo.php");

$oldPwd = $_POST['oldPwd'];
$docPhone = $_POST['docPhone'];
$newPwd = $_POST['newPwd'];

if($oldPwd != $doc_pwd){
    echo "<script type='text/javascript'>alert('原始密码错误！');history.go(-1);</script>";
    exit();
}

if($docPhone != $doc_phone){
    echo "<script type='text/javascript'>alert('手机号码错误！');history.go(-1);</script>";
    exit();
}

$sql = "UPDATE doc_infos set doc_Password = '".$newPwd."' where doc_ID = '".$doc_ID."'";

if($oldPwd === $doc_pwd && $docPhone === $doc_phone){
    $result = mysqli_query($connect_DB, $sql);
    if($result){
        session_unset();
        session_destroy();
        echo "<script type='text/javascript'>alert('密码修改成功！请重新登录！');location='doc_Login.html';</script>";
        $connect_DB->close();
        exit();
    }else{
        echo "<script type='text/javascript'>alert('修改密码失败！请重试！');history.go(-1);</script>";
    }
}
$connect_DB->close();
exit();
?>